﻿/*                       NOTICE
 * 
 * This software was produced for the U. S. Government
 * under Contract No. FA8721-10-C-0001, and is
 * subject to the Rights in Noncommercial Computer Software
 * and Noncommercial Computer Software Documentation Clause
 * (DFARS) 252.227-7014 (JUN 1995)
 * 
 * Approved for Public Release: 11-2435
 * © 2011 The MITRE Corporation. All Rights Reserved. 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TUIO;

namespace GRIP.Gestures
{
    public enum GestureCardinality
    {
        Left,
        Right,
        Generic
    }

    public enum GestureEventType
    {
        Added,
        Changed,
        Removed
    }

    public class GestureEvent<T> where T : Gesture
    {
        public GestureEventType EventType;
        public T Gesture;

        public GestureEvent(T Gesture, GestureEventType EventType)
        {
            this.Gesture = Gesture;
            this.EventType = EventType;
        }
    }

    public class GestureEventArgs<T> : EventArgs where T : Gesture
    {
        private T g;
        private long fn;

        public GestureEventArgs(T Gesture, long FrameNumber)
        {
            this.g = Gesture;
            this.fn = FrameNumber;
        }

        public T Gesture
        {
            get { return g; }
        }

        public long FrameNumber
        {
            get { return fn; }
        }
    }

    /// <summary>
    /// Extremely abstract class, used to define simple
    /// methods that all gestures can override with custom
    /// behavior.
    /// </summary>
    public abstract class Gesture
    {
        public DateTime StartTime;
        public DateTime EndTime;
        public long ID;
        public string Source;

        public Gesture(DateTime Time, long ID, string Source)
        {
            this.StartTime = Time;
            this.ID = ID;
            this.Source = Source;
        }

        public abstract void OnAdded(ContactFrameReadyEventArgs Frame);
        public abstract void OnChanged(ContactFrameReadyEventArgs Frame);
        public abstract void OnRemoved(ContactFrameReadyEventArgs Frame);

        public abstract System.Xml.XmlElement ToXML();
    }
}
